#{extends 'organization.html' /}
#{set title: 'My Organizations'/}
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type"
	content="text/html; charset=windows-1256">

	<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
	<script type="text/javascript">
		
		function leaveOrg(name,developerID,organizationID) {
			var answer = confirm("Are you sure you want to leave " + name + "? This cannot be undone.");
			
			if (answer) {
				$.ajax({
				   		type: "GET",
				   		url: "/Organizations/removeIdeaDeveloperFromOrganization",
				   		dataType: "html",
				   		data: "ideaDeveloperID="+developerID+"&organizationID="+organizationID,
				   		success: function(html){
				     		$("#orgList").replaceWith($("#orgList", html));
				   		}
				 	});
			}
		}

	</script>
	
	<STYLE TYPE='text/css'>
	.removeBot {
		position:relative;
		bottom: -5px;
	}
	
	.members {
		padding: 0px;
		Display:inline;
	}
	
	
	
	</STYLE>

</head>
<body>
#{if session.get("username") == null}
<div class="error">
	<p class="error"> You must be connected to edit an organization </p>
</div>
<br></br>

</style>

<script type="text/javascript">

      $(document).ready(function() {
	
 		$('#background').hide().addClass( 'positioned' ); 
 			});
</script>

<a href = "@{Secure.login()}" class ="standardLink" > login now</a>
<a href="@{Users.register()}" class ="standardLink">New user? register now!</a>
#{/if}

<div id="background">
<h1> Your Organization:</h1>
<br><br/>
<div id="orgList">

	#{table result, as:'product'}
	#{column 'Organization Name'}
	<a id="entity" href=@{Browse.viewOrganization(product.id)}>
    ${product.name}
	</a>
	
<!-- If the user is an idea developer in the organization he can leave the org.-->
#{if product.isIdeaDeveloper(user.id)}
	<form class="members" action = "javascript: leaveOrg('${product.name}',${user.id},${product.id});" method="post">
  		<input class="removeBot" type="image" name="leaveOrg" src="@{'/public/images/Remove-icon.png'}" width="20" height="20">
	</form>
#{/if}
	<br></br>
#{if user.isOrganizationLead(product.id) || user.isSysteAdmin()}
	<a id="editing" class="standardLink" href="@{Organizations.editOrg(product.id)}"> Edit Organization </a><br>
	<a id="editing" class="standardLink" href="@{Organizations.deleteOrg(product.id)}"> Delete Organization </a>	
#{/if}
#{/column}
	
#{column 'Lead\'s Name'}
<p> 
#{if product.getOrganizationLead()!=null}
${product.getOrganizationLead().name}
#{/if}
#{else}
No Lead has been assigned
#{/else}
</p>
#{/column}

	#{/table} 

</div>

<style type="text/css">
#entity{
		font-family: Verdana, helvetica;
		font-size: 1.5em;
}
	#editing{
		font-style: italic;
	}
</style>
</body>
</div>
</html>